#include <ros/ros.h>
#include <signal.h>
#include <sstream>

using namespace std;
Node_manager node;

void Handle(int s){
  if(s == 2)
  {
      node.DestroyMemory();
      exit(0);
  }
} 
void test_function(){
    cout<<"hello world!\n";
}
string ltos(long l)
{
    ostringstream os;
    os<<l;
    string result;
    istringstream is(os.str());
    is>>result;
    return result;
}
int main()
{
    string a;
    a.resize(100); 
    a=ltos((long)test_function);
    signal(2,Handle);
    node.CreateMemory();
    while(1)
    {
        // cout << "Ultimate Super Memory Test: " << endl;
        // scanf("%s", &a[0]);
        // node.WriteMemory(a);
        node.WriteMemory(a);
        string t=node.ReadMemory();
        void (*p)()=(void (*)())stol(t);
        (*p)();
        getchar();
    }
    return 0;
}